package br.edu.fa7.quotes.ui;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import br.edu.fa7.quotes.R;
import br.edu.fa7.quotes.model.Quote;
import br.edu.fa7.quotes.model.QuoteDB;

public class QuoteActivity extends Activity {

	private QuoteDB quoteDB;
	private Quote quote;
	private TextView tv1;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        if(getIntent().getBooleanExtra("sairApp", false)){
			finish();
			return;
		}

        tv1 = (TextView) findViewById(R.id.txtQuote);
		tv1.setText(quoteDB.todaysQuote().getQuote());
        
        if (savedInstanceState != null) {
			quote = (Quote) savedInstanceState.getSerializable("quote");
		}else {
			quote = new Quote();
			TextView tv = (TextView) findViewById(R.id.txtQuote);
			tv.setText(quoteDB.todaysQuote().getQuote());
		}
    }
    
}
